﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Data;
using System.Windows;

namespace WasaWasa.Converters
{
    public class CompareConverter<T> : IValueConverter
    {
        public CompareType CompareType { get; set; }
        public T StandardValue { get; set; }

        #region IValueConverter メンバ

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            switch (CompareType)
            {
                case CompareType.Equalls:
                    return value.Equals(StandardValue);
                case CompareType.GreaterThan:
                    return (value as IComparable).CompareTo(StandardValue) > 0;
                case CompareType.LowerThan:
                    return (value as IComparable).CompareTo(StandardValue) < 0;
            }
            return false;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new Exception("Not implemented.");
        }

        #endregion
    }

    public enum CompareType
    {
        Equalls,
        GreaterThan,
        LowerThan,
    }
}
